# Copyright (c) 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# GNU Makefile based on shared rules provided by the Native Client SDK.
# See README.Makefiles for more details.

VALID_TOOLCHAINS := pnacl

NACL_SDK_ROOT ?= $(shell find ../.. -type d -regex '.*/nacl_sdk/pepper_[0-9]+' \
				             | sort | head -n1)

../crouton/kiwi.pexe: pnacl/Release/kiwi.pexe
	cp pnacl/Release/kiwi.pexe ../crouton/kiwi.pexe

include $(NACL_SDK_ROOT)/tools/common.mk


TARGET = kiwi
LIBS = ppapi_cpp ppapi

CFLAGS = -Wall -std=gnu++11
SOURCES = kiwi.cc

# Build rules generated by macros from common.mk:
$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))

ifeq ($(CONFIG),Release)
$(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS)))
$(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped))
else
$(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS)))
endif

$(eval $(call NMF_RULE,$(TARGET),))
